package com.chunxuan.langquan.dao.http;

import android.text.TextUtils;
import com.chunxuan.langquan.base.Global;
import com.chunxuan.langquan.support.util.Logg;

import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Response;

// 获取响应头的token,解决登录过期的问题
public class TokenInterCeptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Response response = chain.proceed(chain.request());

//        String headerToken = response.header("Authorization");
        String headerToken = response.header("");

//        Logg.e("请求头headerToken = " + headerToken);

        if (!TextUtils.isEmpty(headerToken)) {
            Global.HEADER = headerToken;
        }
        return response;
    }
}
